﻿using System;
using ExtraClub.Domain;
using ExtraClub.Domain.Entities;
using SubSonic;
using System.Collections.Generic;
using ExtraClub.Domain.Forms;

namespace ExtraClub.Web.Forms.client_filter {
    public partial class module : BaseFilter {
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
        }

        protected override string SetFields() {
            return BuildFilterForm();
        }

        private string BuildFilterForm() {
            string key = "client_grid_filter";
            Dictionary<string, object> data = (Dictionary<string, object>)Session[key];

            FieldCollection fs = new FieldCollection();
            fs.Control = this;
            fs.LabelKeySuffex = "-label";

            AddHiddenFieldes(ref fs, "");

            /* User Name */
            new Field(FieldType.String, Client.Columns.FirstName.ToLower(), f=> {
                f.Size = Client.Schema.GetColumn(Client.Columns.FirstName).MaxLength;
                f.Value = data != null ? data[f.CodeName].ToString() : "";
            }, fs);

            return fs.JSON();

        }
    }
}
